import inspect
from settings import settings
from common.base.base_api import BaseApi
from services.new_services.technic_page.schemas.block_type import BlockTypeRequest

from services.new_services.technic_page.schemas.technic_configuration import TechnicConfiguration


class TechnicPageApi(BaseApi):
    __slots__ = []

    def __init__(self):
        super(TechnicPageApi, self).__init__(request_queue_uuid=settings.TECHNIC_PAGE_ROUTER_REQUEST_QUEUE)

    async def enable_cp(self, user_role: str):
        return await self.send_rpc_request_message(
            inspect.currentframe().f_code.co_name,
            {
                'user_role': user_role
            }
        )

    async def get_cp_status(self):
        return await self.send_rpc_request_message(inspect.currentframe().f_code.co_name)

    async def get_cviya_list(self, block_type: BlockTypeRequest):
        return await self.send_rpc_request_message(
            inspect.currentframe().f_code.co_name,
            {
                'block_type': block_type
            }
        )

    async def clear_alarms(self):
        return await self.send_rpc_request_message(inspect.currentframe().f_code.co_name)

    async def get_technic_page_information(self):
        return await self.send_rpc_request_message(inspect.currentframe().f_code.co_name)

    async def set_unit_config_by_technic(self, config: TechnicConfiguration, user_role: str = 'user'):
        return await self.send_rpc_request_message(
            inspect.currentframe().f_code.co_name,
            {
                'config': config,
                'user_role': user_role
             }
        )
